<?php
//=========================
//Vuong Van Binh
//Wanbin@vietnambiz.com
//Message
//=========================
include ADMIN_INCLUDE_DIR."/header.php";
//ACTION DELETE
del_message();
del_multi_message();
//=========================
//GET DATA FROM DATABASE PER PAGE

$rs_message = get_all_message_page();

//Current URL
if($_GET["mode"]=="sent"){
	$str_url = "&mode=sent";
	$mode_field = "To";
}else{
	$str_url="&mode=inbox";
	$mode_field = "From";
}
//=========================
?>
<div class="container_l">

		<div class="title_user"><img src="images/icon4.gif" />All Feedback
		
			<span style="float:right; padding:2px; display:inline; margin-top:5px;">
			<select name="mode" id="mode" onchange="view_mode('<?php echo ADMIN_URL;?>');" style="height:28px; width:120px; font-size:11px; font-weight:bold; color:#375B91; text-transform:none">
			<option value="inbox" <?php if($_GET["mode"]=='inbox'){echo "selected='selected'"; } ?> >Inbox Message</option>
			<option value="sent" <?php if($_GET["mode"]=='sent'){echo "selected='selected'"; } ?>>Sent Message</option></select>
			</span>
			
		</div>
		
		<div class="table_user">
		<form name="del_check" action="" method="post" id="form_del_check">
			<div class="table_user_in">
				<div class="boxtitle">
					<div class="d_input" style="width:3%"><input type="checkbox" name="checkall" id="checkall" value="" /></div>
					<div class="d_title" style="width:47%; text-align:left">&nbsp;&nbsp;&nbsp;Subject</div>
					<div class="d_datetime" style="width:20%">Date Send</div>
					<div class="d_cate" style="width:10%"><?php echo $mode_field; ?> </div>
					<div class="d_statusnews" style="width:7%">Read</div>
					<div class="d_setting" style="width:12%">Setting</div>
				</div>
			<?php
	
					while($value=$db->fetch_array($rs_message["message"])){
						
						if($value['read']=="Yes"){
							$value['read'] = "<font color = black>".$value['read']."</font>";
						}	
				
			?>
				<div class="lineuser">
					<div class="d_input2" style="width:3%"><input type="checkbox" name="check[]" id="check" class="check" value="<?php echo $value["mes_id"]; ?>" /></div>
					<div class="d_title2" style="width:47%"><font class="textbody">
					<a href="<?php echo ADMIN_URL; ?>/index.php?module=member-message-preview&id=<?php echo $value["mes_id"].$str_url; ?>&keepThis=true&TB_iframe=true&height=250&width=410" class="thickbox" title="<?php if($_GET["mode"]=="sent"){ echo "<font color='#0066CC'><b>Sent Messages</b></font>"; }else{ echo "<font color='#0066CC'><b>Inbox Messages</b></font>";} ?>" ><?php echo $value["title"]; ?></a></font></div>
					<div class="d_datetime2" style="width:20%;text-align:center"><font class="textbody"><?php echo get_my_date($value['senddate']); ?></font></div>
					<div class="d_cate2" style="width:10%;text-align:center"><font class="textbody"><?php echo $value["username"]; ?></font></div>
					<div class="d_statusnews2" style="width:7%;text-align:center;"><font color="#FF0000"><?php echo $value["read"]; ?></font></div>
					<div class="d_setting2" style="width:12%">
					<a href="<?php echo ADMIN_URL; ?>/index.php?module=member-message-preview&id=<?php echo $value["mes_id"].$str_url; ?>&keepThis=true&TB_iframe=true&height=250&width=410" class="thickbox" title="<?php if($_GET["mode"]=="sent"){ echo "<font color='#0066CC'><b>Sent Messages</b></font>"; }else{ echo "<font color='#0066CC'><b>Inbox Messages</b></font>";} ?>" >
						<img src="images/profile.gif" alt="view" title="view" />
					</a>
					<a onclick="confirm_get('Are you sure to delete : <b><?php echo replace_quot($value["title"]); ?></b> ?','<?php echo get_string_url(array('del'));?>&del=<?php echo $value["mes_id"]?>');" href="javascript:void(0);">
						<img src="images/delete.gif" alt="Delete" title="Delete" />
					</a>
					
					</div>
				</div>
				
			<?php 		} ?>
				
				<div class="boxbutton">
					<input type="hidden" name="del_multi" value="okie" />
					<input type="button" value="Delete checked" class="button" onclick="confirm_post('Are you sure to delete all checked','form_del_check');" />
					<input type="button" name="delete" value="Cancel" id="cancel" class="button" />
					&nbsp;<a href="index.php?module=myaccount&option=add-message"><img src="images/addnew.gif" border="0" /></a>
				</div>
			</form>
			<?php
				    // SHOW PAGING
				    if($rs_message["total"]>1){ 
				    echo "<div class='lineinbox'>";
					echo paging($rs_message["page"],$rs_message["total"],get_string_url());
					echo "</div>";
					}
			?>
				
			</div>
		</div>
	</div>
<script type="text/javascript">
	function view_mode(baseurl)
	{
	  var mode = document.getElementById('mode').value;
	 
	  window.location = baseurl+'/index.php?module=member&option=feedback&mode='+mode;
	}

</script>
<?php
include "inc/right.php"; 
include ADMIN_INCLUDE_DIR."/footer.php"; 
?>